package com.example.demo.xcel;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentFontStyle;
import com.alibaba.excel.annotation.write.style.ContentStyle;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author FENGYU
 * @description
 * @date 2023/8/31 15:12
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
// 行高
@HeadRowHeight(25)
// 行宽
@ColumnWidth(30)
@ContentFontStyle()
@ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.CENTER)
public class TUser {
    // 每列名称

    @ExcelProperty(index = 1, value = "提成员工实际部门")
    private String readDeptName;

    @ExcelProperty(index = 5, value = "产品名")
    private String pname;


    @ExcelProperty(index = 10, value = "员工姓名")
    private String userName;


    @ExcelProperty(index = 16, value = "发放期数")
    private String periodNum;

    @ExcelProperty(index = 17, value = "发放金额")
    private String releaseAmount;

    public static void main(String[] args) {
        System.out.println(negative("1,237.50"));
    }

    public static double negative(String str) {
        str = str.replace(",", "");
        boolean isNegative = str.startsWith("-");

        if (isNegative) {
            str = str.substring(1);
        }

        double number = Double.parseDouble(str);

        if (isNegative) {
            number = -number;
        }

        return number;
    }

    public static boolean perinumAble(String periodNum) {

        try {
            return periodNum != null && (Integer.parseInt(periodNum) == 0 || "0.0".equals(periodNum));
        } catch (Exception e) {
            return "0.00".equals(periodNum) || "0.0".equals(periodNum) || "0".equals(periodNum);
        }

    }

}
